<?php

require_once dirname(__FILE__).'/../lib/estudianteGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/estudianteGeneratorHelper.class.php';

/**
 * estudiante actions.
 *
 * @package    sistema_estadisticas
 * @subpackage estudiante
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class estudianteActions extends autoEstudianteActions
{

	public function executeBuscar(sfWebRequest $request)
	{
		if ($request->isXmlHttpRequest())
		{
			$dato = $request->getParameter('value');

			if(isset($dato[2]))
			{
				$resultados = EstudianteTable::getInstance()->findByValue($dato);
				$json_data = array();
				foreach ($resultados as $estudiante)
					$json_data[] = array('id' => $estudiante->getId(), 'value' => $estudiante->__toString());
					
				return $this->renderText(json_encode($json_data));
			}

			return $this->renderText(json_encode(array()));
		}
		else
			$this->forward404('Acceso incorrecto');
	}

}
